package Homework3;

import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Homework3_7 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int m = input.nextInt();
        int n = input.nextInt();
        input.nextLine();

        if (m < 1 || m > n) {
            System.out.println("m is out of range");
            return;
        }

        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] = input.nextLine();
        }

        Arrays.sort(strings, Collections.reverseOrder());

        System.out.println(strings[m-1]);
    }
}

